package com.tt.service.impl;

import com.tt.mapper.DepartmentApparentTotalMapper;
import com.tt.mapper.EnumYearMapper;
import com.tt.service.TimeSelectorService;
import com.tt.util.HandleDecimal;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * <p>
 *
 * </p>
 *
 * @version 1.0
 * @auther sugarttt
 * @since 2022-11-10 10:32:48
 */
@Service
public class TimeSelectorServiceImpl implements TimeSelectorService {

    private final EnumYearMapper enumYearMapper;
    private final DepartmentApparentTotalMapper departmentApparentTotalMapper;

    public TimeSelectorServiceImpl(EnumYearMapper enumYearMapper, DepartmentApparentTotalMapper departmentApparentTotalMapper) {
        this.enumYearMapper = enumYearMapper;
        this.departmentApparentTotalMapper = departmentApparentTotalMapper;
    }

    @Override
    public ArrayList<String> getYears() {
       return enumYearMapper.getYears();
    }

    @Override
    public ArrayList<Double> getAllEmission() {
        ArrayList<Double> resultDouble = new ArrayList<>();
        ArrayList<String> resultString = departmentApparentTotalMapper.getAllEmission();
        for (String value: resultString){
            resultDouble.add(HandleDecimal.handle(value));
        }
        return resultDouble;
    }
}
